package top.kaoshanji.r3ch11c;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

/**
 * @author kaoshanji
 * ^_^
 * create time 2025/5/9 14:28
 */
@Repository
public class TopicDao {

    private JdbcTemplate jdbcTemplate;

    @Autowired
    public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
        this.jdbcTemplate = jdbcTemplate;
    }


    public void addTopic(final Topic topic) {
        final String sql = " INSERT INTO t_topic(topic_title) VALUES(?) ";

        Object[] params = new Object[]{topic.getTopicTitle()};
        jdbcTemplate.update(sql, params);
    }


}
